<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
    <meta http-equiv="Cache-Control" content="no-siteapp" />
    <link rel="Bookmark" href="/favicon.ico">
    <link rel="Shortcut Icon" href="/favicon.ico" />
    <title>添加配置</title>
    <!--[if lt IE 9]>
    <script type="text/javascript" src="lib/html5shiv.js"></script>
    <script type="text/javascript" src="lib/respond.min.js"></script>
    <![endif]-->
    <link rel="stylesheet" type="text/css" href="../static/h-ui/css/H-ui.min.css" />
    <link rel="stylesheet" type="text/css" href="../static/h-ui.admin/css/H-ui.admin.css" />
    <link rel="stylesheet" type="text/css" href="../lib/Hui-iconfont/1.0.9/iconfont.css" />
    <link rel="stylesheet" type="text/css" href="../static/h-ui.admin/skin/default/skin.css" id="skin" />
    <link rel="stylesheet" type="text/css" href="../static/h-ui.admin/css/style.css" />
    <link rel="stylesheet" href="./../lib/layui/css/layui.css">
    <!--[if IE 6]>
    <script type="text/javascript" src="lib/DD_belatedPNG_0.0.8a-min.js" ></script>
    <script>DD_belatedPNG.fix('*');</script>
    <![endif]-->
</head>

<body>
    <div class="page-container">
            <form action="" method="post" class="form form-horizontal" id="form-article-add">
                    <input type="" name="" id="visible_input" value="1" style="display:none;" />
                    <input type="" name="" id="isDiscount_input" value="2" style="display:none;" />
                    <input type="" name="" id="isHot_input" value="2" style="display:none;" />
            <div class="row cl" style = "margin-bottom: 10px;">
            <label class="form-label col-xs-4 col-sm-2">连续签到天数：</label>
            <div class="formControls col-xs-8 col-sm-8">
                <input type="text" class="input-text" value="" placeholder="" id="signInNo" name="">
            </div>
        </div>
        <div class="row cl" style = "margin-bottom: 10px;">
            <label class="form-label col-xs-4 col-sm-2">签到奖品：</label>
            <div class="col-xs-8 col-sm-8">
                <select name="" style="width: 100%" class="input-text" id="giftBag" style="width:10%;">
                </select>
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-2"></label>
            <button onClick="save_submit();" class="btn btn-primary radius" type="button">提交</button>

            <button onClick="layer_close();" class="btn btn-default radius" type="button">&nbsp;&nbsp;关闭&nbsp;&nbsp;</button>

        </div>
    </div>
    <script src="./../static/jquery.min.js"></script>
    <script type="text/javascript" src="./../static/js/common.js"></script>
    <script type="text/javascript" src="../lib/layer/2.4/layer.js"></script>
    <script type="text/javascript" src="./../lib/layui/layui.js"></script>
    <script>
        $(function(){
            $.ajax({
                type: "post",
                xhrFields: {
                    withCredentials: true
                },
                url: admin_url + '/kvmGiftProduct/getGifts',
                data: {
                    tokenUserId: userId,
                    token: token
                },
                success:function(data){
                    if(data.code ==200 && data.data != null){
                        console.log(data)
                        for(var i = 0; i < data.data.length;i++){
                    $("#giftBag").append('<option value = "' + data.data[i].id + '">' + data.data[i].name + '</option>')

                        }

                    }else{

                    }
                }
            })
        })
        function save_submit(){
            if( $("#signInNo").val() == ''){
                layer.msg("请输入连续签到天数")
            }else{
            var signInNo = $("#signInNo").val(),
            giftBag = $("#giftBag option:selected").val();
            $.ajax({
                type: "post",
                xhrFields: {
                    withCredentials: true
                },
                url: admin_url + '/kvmSigninGiftSeting/addSigninGiftSeting',
                data: {
                    tokenUserId: userId,
                    token: token,
                    signInNo: signInNo,
                    giftProductId:giftBag
                },
                success:function(data){
                    if (data.code == 200) {
                            layer.msg('配置成功', {
                                time: 1000,
                                end: function () {

                                    var index = parent.layer.getFrameIndex(window.name);
                                    parent.layer.close(index);
                                    $(window.parent.document).find('.layui-laypage-btn').click()
                                    
                                }
                            })
                        } else {
                            layer.msg(data.msg, {
                                time: 1500
                            })
                        }
                }
            })
            }
            
        }
                // 取消功能
                function layer_close() {
            var index = parent.layer.getFrameIndex(window.name);
            parent.layer.close(index);
        }

    </script>
</body>

</html>